package org.example;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.TimeZone;

public class SetCookieExample {
    public static void main(String[] args) {
        SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);
        sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
        String expiresDate = sdf.format(new Date()); // 当前时间的 RFC 1123 格式

        // 构造 Set-Cookie header
        String cookieHeader = String.format(
                "JSESSIONID=B9A3C8D6D27C262C9EE2C7A736FE4F3D; SameSite=None; Secure; HttpOnly; Expires=%s",
                expiresDate
        );

        System.out.println("Set-Cookie Header: " + cookieHeader);
    }
}
